<html>
<head><meta charset="utf-8"><title>associated consts in traits (solved) · general · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/index.html">general</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/associated.20consts.20in.20traits.20(solved).html">associated consts in traits (solved)</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="204178092"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/associated%20consts%20in%20traits%20%28solved%29/near/204178092" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Sebastian Köln <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/associated.20consts.20in.20traits.20(solved).html#204178092">(Jul 17 2020 at 07:35)</a>:</h4>
<p>Greetings. <br>
I swear this worked before?</p>
<div class="codehilite"><pre><span></span><code>trait FixedSize: Sized {
    const SIZE: usize;
}

trait AsArray: FixedSize {
    fn as_array(&amp;self) -&gt; [u8; Self::SIZE];
}
</code></pre></div>



<a name="204178181"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/associated%20consts%20in%20traits%20%28solved%29/near/204178181" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Sebastian Köln <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/associated.20consts.20in.20traits.20(solved).html#204178181">(Jul 17 2020 at 07:36)</a>:</h4>
<p>or did I misrember and one had to use type Array = [u8; 42];</p>



<a name="204178855"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/associated%20consts%20in%20traits%20%28solved%29/near/204178855" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Sebastian Köln <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/associated.20consts.20in.20traits.20(solved).html#204178855">(Jul 17 2020 at 07:45)</a>:</h4>
<p>either way, I am getting some interesting errors: <a href="https://play.rust-lang.org/?version=beta&amp;mode=debug&amp;edition=2018&amp;gist=695bf16779ddeda87b3ab5a06f14fa12">https://play.rust-lang.org/?version=beta&amp;mode=debug&amp;edition=2018&amp;gist=695bf16779ddeda87b3ab5a06f14fa12</a></p>



<a name="204178870"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/associated%20consts%20in%20traits%20%28solved%29/near/204178870" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Sebastian Köln <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/associated.20consts.20in.20traits.20(solved).html#204178870">(Jul 17 2020 at 07:45)</a>:</h4>
<p>error[E0277]: the trait bound <code>A: AsArray</code> is not satisfied<br>
on <code>impl&lt;A: AsArray, B: AsArray&gt; AsArray for (A, B) {</code></p>



<a name="204180989"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/associated%20consts%20in%20traits%20%28solved%29/near/204180989" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Sebastian Köln <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/associated.20consts.20in.20traits.20(solved).html#204180989">(Jul 17 2020 at 08:13)</a>:</h4>
<p>Okay, so  I am running  into a well known limitation. Disregard.</p>



<a name="204188783"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/associated%20consts%20in%20traits%20%28solved%29/near/204188783" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/associated.20consts.20in.20traits.20(solved).html#204188783">(Jul 17 2020 at 09:53)</a>:</h4>
<p><span class="user-mention" data-user-id="257700">@Sebastian Köln</span> this is the error you should be getting <a href="https://play.rust-lang.org/?version=nightly&amp;mode=debug&amp;edition=2018&amp;gist=26e23c4d11cf2b4bfe91f9597601ee89">https://play.rust-lang.org/?version=nightly&amp;mode=debug&amp;edition=2018&amp;gist=26e23c4d11cf2b4bfe91f9597601ee89</a></p>



<a name="204188845"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/associated%20consts%20in%20traits%20%28solved%29/near/204188845" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/associated.20consts.20in.20traits.20(solved).html#204188845">(Jul 17 2020 at 09:54)</a>:</h4>
<p>(the const generics feature-gate doubles as an opt-in for turning on "lazy normalization" which fixes the false error you were seeing, and reveals the true error)</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>